# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=zmap
pkgver=2.1.1
pkgrel=8
pkgdesc="A high performance internet scanner"
url="https://www.zmap.io/"
arch="all"
license="Apache-2.0"
makedepends="linux-headers cmake flex byacc hiredis-dev json-c-dev gengetopt
	libpcap-dev gmp-dev"
checkdepends="bash"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz
	byacc.patch"
builddir="$srcdir"/$pkgname-$pkgver

build() {
	cd "$builddir"
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_CXX_COMPILER="${CXX:-g++}" \
		-DCMAKE_C_COMPILER="${CC:-gcc}" \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_CXX_FLAGS="$CFLAGS" \
		-DWITH_JSON=ON \
		-DWITH_REDIS=ON
	make
}

check() {
	cd "$builddir"/test
	./test_big_group.sh
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	mkdir -p "$pkgdir"/usr/share/doc/$pkgname/
	install -m644 AUTHORS CHANGELOG.md INSTALL.md README.md \
		"$pkgdir"/usr/share/doc/$pkgname/
	cp -a examples "$pkgdir"/usr/share/doc/$pkgname/
}

sha512sums="9d62dceff77fa20ff5945516b0766340366175947130bb844f19c11dac7676e658bcdedd6be29ffc945706aa3cdc0e4ac207bd127b618592769a4d3e75892857  zmap-2.1.1.tar.gz
08cc497d99e388af2c0dd0d8a2337fa901451dd0b256bd4cfcc91a12ff1da503773214d0768077aae56e70cc5c49724be88064dd25eeaa3947f2a993af4215b8  byacc.patch"
